//
//  CompangZPTableViewCell.m
//  u76ho
//
//  Created by m-air-01 on 16/1/6.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "CompangZPTableViewCell.h"

@implementation CompangZPTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
-(void)setDataArr:(NSArray *)dataArr
{
    _dataArr = dataArr;
    int j = 0;
    CGFloat btnWidth = (SCREEN_WIDTH - SIZETO6W(15)*2 - SIZETO6W(10))/2;
    for (int i = 0; i<dataArr.count; i++) {
        CompanyDetailZPModel * model = dataArr[i];
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        int loc=i%2;//列号
        if (i%2 == 0) {
            j++;
        }
        btn.frame = CGRectMake(SIZETO6W(15) + loc * (btnWidth + SIZETO6W(10)), SIZETO6H(10) + (j-1)*(SIZETO6H(10 + 30)), btnWidth, 30);
        [btn setTitle:model.dutyname forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        btn.tag = i + 1;
        [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
    }
}
-(void)btnAction:(UIButton *)btn
{
    CompanyDetailZPModel * model = [_dataArr objectAtIndex:(btn.tag - 1)];
    _btnSelectedBlock(model.jid);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
